import request from '@/config/axios'

// 呼叫记录 VO
export interface CloudcallLogVO {
  id: number // id
  name: string // 联系人名称
  source: string // 来源类型如customer，clues
  sourceId: number // 来源数据ID
  adminId: number // 员工ID
  fromExten: string // 坐席工号
  status: number // 0数据未回传-1未接通1已同步2同步失败
  callNo: string // 呼叫号码
  calledNo: string // 被呼叫号码
  recordFile: string // 录音文件
  callTimeLength: number // 呼叫时长(秒)
  extenType: string // 接听方式
  actionId: string // 呼叫事件ID
}

// 呼叫记录 API
export const CloudcallLogApi = {
  // 查询呼叫记录分页
  getCloudcallLogPage: async (params: any) => {
    return await request.get({ url: `/crm/cloudcall-log/page`, params })
  },

  // 查询呼叫记录详情
  getCloudcallLog: async (id: number) => {
    return await request.get({ url: `/crm/cloudcall-log/get?id=` + id })
  },

  // 新增呼叫记录
  createCloudcallLog: async (data: CloudcallLogVO) => {
    return await request.post({ url: `/crm/cloudcall-log/create`, data })
  },

  // 修改呼叫记录
  updateCloudcallLog: async (data: CloudcallLogVO) => {
    return await request.put({ url: `/crm/cloudcall-log/update`, data })
  },

  // 删除呼叫记录
  deleteCloudcallLog: async (id: number) => {
    return await request.delete({ url: `/crm/cloudcall-log/delete?id=` + id })
  },

  // 导出呼叫记录 Excel
  exportCloudcallLog: async (params) => {
    return await request.download({ url: `/crm/cloudcall-log/export-excel`, params })
  }
}